from database.models.Controller import *
from database.models.Normal import *


class PanelInstruct(Base):
    __tablename__ = 'PanelInstruct'
    id = Column(Integer, primary_key=True, autoincrement=True)
    Name = Column(String, default='')
    NormalID = Column(Integer, ForeignKey('Normals.id'))
    ControllerID = Column(Integer, ForeignKey('Controller.id'))
    Key = Column(Integer, default=-1)
    cid = relationship('Controller', back_populates='panelinstruct')
    nid = relationship('Normal', back_populates='panelinstruct')

    def __repr__(self):
        return "<Controller(id='%d', TypeID='%d')>" % (
            self.id, self.TypeID)


Controller.panelinstruct = relationship('PanelInstruct', order_by=PanelInstruct.id, back_populates='cid')
Normal.panelinstruct = relationship('PanelInstruct', order_by=PanelInstruct.id, back_populates='nid')
